#ifndef GAMEROOM_H
#define GAMEROOM_H

#include<QWidget>
#include<QSound>
//蛇的移动方向
enum moveMent
{
   UP=0,
    DOWN,
    LEFT,
    RIGHT
};

class gameroom : public QWidget
{
    Q_OBJECT
public:
    explicit gameroom(QWidget *parent = nullptr);
  void paintEvent(QPaintEvent *event);
  //移动函数
  void  moveUp();
  void  moveDown();
  void  moveLeft();
  void  moveRight();

signals:

private:
    //一些关于蛇的属性
  //长度，高度，速度，属性
  const int snakeWidth=20;
  const int  snakeHeight=20;
  const  int  snakeSpeed=200;
   //贪吃蛇矩形链表
   QList<QRectF> snakeList;
   QRectF foodNode;//食物结点
   moveMent snakeDireaction=moveMent::UP;
   QTimer* timer;
   bool isGameStart=false;
   //判断游戏是否结束
   bool  checkFail();
   //产生食物
   void creatFood();
   QSound* sound;

};

#endif // GAMEROOM_H
